package com.jswlw.controller.distributor;

import com.jswlw.controller.BaseController;
import com.jswlw.entity.biz.FeedBack;
import com.jswlw.service.biz.FeedBackService;
import com.jswlw.web.manager.SessionDistributorManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author 吴维斌 E-mail:wuweibin0817@163.com
 * @version 创建时间：${date} ${time}
 */
@Controller
@RequestMapping("/distributor/feedBack")
public class DistributorFeedBackController extends BaseController{

    @Autowired
    FeedBackService feedBackService;

    @RequestMapping("index")
    public ModelAndView index() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("/distributor/feedBack/index");
        FeedBack filter=new FeedBack();
        filter.setDistributorIds(SessionDistributorManager.getCurrentUser().getChildrenIds());
        modelAndView.addObject("feedBackList",feedBackService.queryList(filter));
        return modelAndView;
    }

    @RequestMapping("/deal")
    @ResponseBody
    public ModelMap deal(Model model, Integer id) {
        try {
            FeedBack feedBack = new FeedBack();
            feedBack.setId(id);
            feedBack.setStatus(1);
            feedBackService.update(feedBack);
            return this.successResult("处理成功");
        } catch (Exception e) {
            logger.error("处理失败", e);
            return this.failResult("处理失败" + e.getMessage());
        }
    }
}
